package com.ishitong.platform.utils.spring;


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ishitong.freesql.builder.FreeSQLFactoryBuilder;
import com.ishitong.platform.ODApplicationConfig;
import com.ishitong.platform.ODApplicationConfigLoad;

public class PlatformStartLoad
{
	private Log logger = LogFactory.getLog(this.getClass());

	/**
	 * 加载系统freesql配置
	 */
	public void loadFreesql()
	{
		logger.info("#########################模块 freesql加载开始....");
		List<String> freesqlMapper = new ArrayList<String>();
		Map<String, ODApplicationConfig> moduleConfig = ODApplicationConfigLoad.getApplicationConfig();
		Iterator ite = moduleConfig.values().iterator();
		while (ite.hasNext())
		{
			ODApplicationConfig module = (ODApplicationConfig) ite.next();
			List<String> freesqlConfig = module.getFreesqlConfig();
			for (int i = 0; i < freesqlConfig.size(); i++)
			{
				freesqlMapper.add(freesqlConfig.get(i));
			}
		}
		FreeSQLFactoryBuilder.builder(freesqlMapper);
	}

}
